package com.frank.wcld.csxs.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.wcld.csxs.domain.WcldCsxs;
import com.frank.wcld.csxs.service.IWcldCsxsService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 查实线索Controller
 * 
 * @author frank
 * @date 2025-04-07
 */
@Controller
@RequestMapping("/wcld/csxs")
public class WcldCsxsController extends BaseController
{
    private String prefix = "wcld/csxs";

    @Autowired
    private IWcldCsxsService wcldCsxsService;

    @RequiresPermissions("wcld:csxs:view")
    @GetMapping()
    public String 查实线索()
    {
        return prefix + "/csxs";
    }

    /**
     * 查询查实线索列表
     */
    @RequiresPermissions("wcld:csxs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WcldCsxs wcldCsxs)
    {
        wcldCsxs.setCreateBy(getLoginName());
        startPage();
        List<WcldCsxs> list = wcldCsxsService.selectWcldCsxsList(wcldCsxs);
        return getDataTable(list);
    }

    /**
     * 导出查实线索列表
     */
    @RequiresPermissions("wcld:csxs:export")
    @Log(title = "查实线索", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WcldCsxs wcldCsxs)
    {
        List<WcldCsxs> list = wcldCsxsService.selectWcldCsxsList(wcldCsxs);
        ExcelUtil<WcldCsxs> util = new ExcelUtil<WcldCsxs>(WcldCsxs.class);
        return util.exportExcel(list, "查实线索数据");
    }

    /**
     * 新增查实线索
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存查实线索
     */
    @RequiresPermissions("wcld:csxs:add")
    @Log(title = "查实线索", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WcldCsxs wcldCsxs)
    {
        wcldCsxs.setCreateBy(getLoginName());
        return toAjax(wcldCsxsService.insertWcldCsxs(wcldCsxs));
    }

    /**
     * 修改查实线索
     */
    @RequiresPermissions("wcld:csxs:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WcldCsxs wcldCsxs = wcldCsxsService.selectWcldCsxsById(id);
        mmap.put("wcldCsxs", wcldCsxs);
        return prefix + "/edit";
    }

    /**
     * 修改保存查实线索
     */
    @RequiresPermissions("wcld:csxs:edit")
    @Log(title = "查实线索", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WcldCsxs wcldCsxs)
    {
        wcldCsxs.setUpdateBy(getLoginName());
        return toAjax(wcldCsxsService.updateWcldCsxs(wcldCsxs));
    }

    /**
     * 删除查实线索
     */
    @RequiresPermissions("wcld:csxs:remove")
    @Log(title = "查实线索", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wcldCsxsService.deleteWcldCsxsByIds(ids));
    }
}
